package com.example.hp.login;

import android.app.Activity;

import android.content.Intent;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.RadioButton;

import android.widget.Toast;


public class Login extends Activity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_login);
        Button login1 = (Button) findViewById(R.id.Login1);
        login1.setOnClickListener(myOnClickListener);
    }
    private View.OnClickListener myOnClickListener = new View.OnClickListener() {
        public void onClick(View v) {
            EditText tv1=(EditText) findViewById(R.id.UserName);
            String username=tv1.getText().toString();

            EditText tv2=(EditText) findViewById(R.id.Password);
            String password=tv2.getText().toString();

            EditText tv3=(EditText) findViewById(R.id.ConfigPassword);
            String configpassword=tv3.getText().toString();

            EditText tv4=(EditText) findViewById(R.id.RealName);
            String realname=tv4.getText().toString();

          RadioButton tv5 = (RadioButton) findViewById(R.id.male);
            RadioButton tv7 = (RadioButton)findViewById((R.id.female));


            EditText tv6=(EditText) findViewById(R.id.Mail);
            String mail=tv6.getText().toString();
            if(!configpassword.equals(password))
            {
                Toast toast1 = Toast.makeText(Login.this,"请保证确认密码与密码相同",Toast.LENGTH_LONG);
                toast1.show();
            }

           else if(username.equals("")||mail.equals("")||password.equals("")||configpassword.equals("")||realname.equals("")||(!tv5.isChecked()&&!tv7.isChecked()))
            {
                Toast toast = Toast.makeText(Login.this, "请填写完整信息", Toast.LENGTH_LONG);
                toast.show();
            }

            else
            {
                Intent intent1 = new Intent();
                intent1.setClass(Login.this,success.class);
                startActivity(intent1);
            }
        }
    };

    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        // Inflate the menu; this adds items to the action bar if it is present.
        getMenuInflater().inflate(R.menu.login, menu);
        return true;
    }

    @Override
    public boolean onOptionsItemSelected(MenuItem item) {
        // Handle action bar item clicks here. The action bar will
        // automatically handle clicks on the Home/Up button, so long
        // as you specify a parent activity in AndroidManifest.xml.
        int id = item.getItemId();
        if (id == R.id.action_settings) {
            return true;
        }
        return super.onOptionsItemSelected(item);
    }
}
